package xyz.syyrjx.blog.entity.ticTacToe;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author 大地崩坏苍蝇兽
 * @date 2024/4/25 19:26
 * @description 玩家类
 * @since v0.0.1
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Gamer {

    // 玩家id
    private String id;


    // 玩家棋子颜色1-红；2-蓝
    private int power;

    // 玩家是否可以行动 0-不可以；1-可以
    private int type;

    // 玩家状态 0-未准备，1-准备
    private int state;

    private int[][] big = new int[3][2];
    {
        for (int i = 0; i < 3; i++) {
            Arrays.fill(big[i], -1);
        }
    }

    public void init() {
        state = 0;
        type = 0;
        big = new int[3][2];
        for (int i = 0; i < 3; i++) {
            Arrays.fill(big[i], -1);
        }
    }

    public void addBig(int x, int y) {
        big[2] = big[1];
        big[1] = big[0];
        big[0] = new int[]{x, y};
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Gamer gamer = (Gamer) o;
        return Objects.equals(id, gamer.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}
